package com.zbkj.admin.controller.platform.v2;

import com.zbkj.admin.model.req.AdminBindBankcardReq;
import com.zbkj.admin.model.req.UnbindMerchantReq;
import com.zbkj.admin.model.req.UpdateBindMerchantReq;
import com.zbkj.admin.service.AdminUserV2Service;
import com.zbkj.service.model.front.req.user.UserLogoffReq;
import com.zbkj.service.model.front.req.user.UserUpdateAuthorityReq;
import com.zbkj.service.model.front.req.user.UpdateUserIdentityReq;
import com.zbkj.dal.base.result.CommonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Api(value = "管理后台用户管理V2")
@RestController
@RequestMapping("/api/admin/platform/v2/user")
public class PlatformUserV2Controller {

    @Resource
    private AdminUserV2Service adminUserV2Service;

    @ApiOperation("修改用户身份")
    @PostMapping("/update/identity")
    public CommonResult<Void> updateUserIdentity(@RequestBody @Validated UpdateUserIdentityReq req) {
        adminUserV2Service.updateUserIdentity(req);
        return CommonResult.success();
    }

    @ApiOperation("修改用户分润权限")
    @PostMapping("/update/share-profit")
    public CommonResult<Void> updateShareProfit(@RequestBody @Validated UserUpdateAuthorityReq req) {
        adminUserV2Service.updateShareProfit(req);
        return CommonResult.success();
    }


    @ApiOperation("用户拉黑/取消拉黑")
    @PostMapping("/operate/blacklist")
    public CommonResult<Void> userBlacklist(@RequestBody @Validated UserUpdateAuthorityReq req) {
        adminUserV2Service.userBlacklist(req);
        return CommonResult.success();
    }

    @ApiOperation(value = "用户注销")
    @PostMapping(value = "/logoff")
    public CommonResult<Void> logoff(@RequestBody @Validated UserLogoffReq req) {
        adminUserV2Service.logoff(req);
        return CommonResult.success();
    }


    @ApiOperation(value = "修改用户绑定银行卡")
    @PostMapping(value = "/update/bind-bank")
    public CommonResult<Void> updateBindBank(@RequestBody @Validated AdminBindBankcardReq req) {
        adminUserV2Service.updateBindBank(req);
        return CommonResult.success();
    }

    @ApiOperation(value = "解绑店铺")
    @PostMapping(value = "/unbind/merchant")
    public CommonResult<Void> unbindMerchant(@RequestBody @Validated UnbindMerchantReq req) {
        adminUserV2Service.unbindMerchant(req);
        return CommonResult.success();
    }

    @ApiOperation(value = "换绑店铺")
    @PostMapping(value = "/update/bind/merchant")
    public CommonResult<Void> updateBindMerchant(@RequestBody @Validated UpdateBindMerchantReq req) {
        adminUserV2Service.updateBindMerchant(req);
        return CommonResult.success();
    }

}
